import 'base_model.dart';

/// 陶瓷作品点赞模型
class CeramicLike implements BaseModel {
  final int? id;
  final int userId; // 点赞用户ID
  final int ceramicId; // 陶瓷作品ID
  final DateTime createdAt; // 创建时间
  final DateTime updatedAt; // 更新时间

  CeramicLike({
    this.id,
    required this.userId,
    required this.ceramicId,
    required this.createdAt,
    required this.updatedAt,
  });

  @override
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'user_id': userId,
      'ceramic_id': ceramicId,
      'created_at': createdAt.millisecondsSinceEpoch,
      'updated_at': updatedAt.millisecondsSinceEpoch,
    };
  }

  factory CeramicLike.fromJson(Map<String, dynamic> json) {
    return CeramicLike(
      id: json['id'],
      userId: json['user_id'],
      ceramicId: json['ceramic_id'],
      createdAt: DateTime.fromMillisecondsSinceEpoch(json['created_at']),
      updatedAt: DateTime.fromMillisecondsSinceEpoch(json['updated_at']),
    );
  }
}

/// 陶瓷作品收藏模型
class CeramicFavorite implements BaseModel {
  final int? id;
  final int userId; // 收藏用户ID
  final int ceramicId; // 陶瓷作品ID
  final DateTime createdAt; // 创建时间
  final DateTime updatedAt; // 更新时间

  CeramicFavorite({
    this.id,
    required this.userId,
    required this.ceramicId,
    required this.createdAt,
    required this.updatedAt,
  });

  @override
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'user_id': userId,
      'ceramic_id': ceramicId,
      'created_at': createdAt.millisecondsSinceEpoch,
      'updated_at': updatedAt.millisecondsSinceEpoch,
    };
  }

  factory CeramicFavorite.fromJson(Map<String, dynamic> json) {
    return CeramicFavorite(
      id: json['id'],
      userId: json['user_id'],
      ceramicId: json['ceramic_id'],
      createdAt: DateTime.fromMillisecondsSinceEpoch(json['created_at']),
      updatedAt: DateTime.fromMillisecondsSinceEpoch(json['updated_at']),
    );
  }
}
